<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Home\Article;

class ArticleController extends Controller
{
    public function index(Article $art,$id)
    {
        $art->where('id',(int)$id)->increment('read_num');
        $article = $art
            ->select('article.*','admin_users.name as author','article_category.name as cate_name','tag.tag_name')
            ->join('admin_users','admin_users.id','=','article.user_id')
            ->leftJoin('article_category','article_category.id','=','article.cate_id')
            ->leftJoin('tag','tag.id','=','article.tag_id')
            ->find((int)$id);
        return view('Home.article',compact('article'));
    }
}
